﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using _MetalSlug.MyCharacters.Characters;
namespace _MetalSlug.Soldiers.Units
{
    using GifAnimation;
    using _MetalSlug.Mission;

    public class Tycoon : Enemy
    {
        GifAnimation tycoonTextures;
        public GifAnimation TycoonTextures
        {
            get { return tycoonTextures; }
            set { tycoonTextures = value; }
        }

        public override void LoadContent()
        {
            DieTexture2Ds = GameUtil.LoadTextures("Boom/Explode",16);
            TycoonTextures = GameUtil.LoadGif("Solider/keesi3");
            StandTexture2Ds = new List<Texture2D>();
            StandTexture2Ds.Add(TycoonTextures.GetTexture());
            ShotTexture2Ds = RunTexture2Ds = StandTexture2Ds;
            
        }

        public Tycoon(int ID)
        {
            id = ID;
        }

        public Tycoon(Vector2 topleft, Vector2 size)
        {
            Type = TYPE_SOLDIER.TYCOON;
            InitialAttribute(topleft, size);        
            Hp = 500;
            DistanceChase = new Segment { Min = 10, Max = 800 };
            DistanceShoot = new Segment { Min = 0, Max = 350 };
            DistanceFlip = 0;
        }

        protected override void Shoot()
        {

        }

        public override void UpdateBullet(GameTime theGameTime, MyMap map, MyCharacter Hero)
        {
        }

        public override void Draw(SpriteBatch spriteBatch)
        {
            if (!(CurrentTextures == DieTexture2Ds && IndexCurrent == DieTexture2Ds.Count-1))
            {
                Vector2 newPos = TopLeft - new Vector2(GameUtil.GamePivot.PivotPoint,0);
                if (CurrentTextures == DieTexture2Ds)
                {
                    spriteBatch.Draw(CurrentTextures[IndexCurrent], new Rectangle((int)newPos.X, (int)newPos.Y, (int)Size.X, (int)Size.Y), Color.White);
                }
                else
                {
                    spriteBatch.Draw(TycoonTextures.GetTexture(), new Rectangle((int)newPos.X, (int)newPos.Y, TycoonTextures.Width + 200, TycoonTextures.Height + 200), Color.White);
                } 
            }
            else
            {
                isDead = true;
            }
        }


        public override void Update(GameTime gameTime, MyMap map, MyCharacter Hero)
        {
            TycoonTextures.Update(gameTime.ElapsedGameTime.Ticks);
            base.Update(gameTime, map, Hero);
        }
          
        public override void UpdateTexture()
        {
            Time++;
            if (Hp <= 0)
            {
                if (time % 10 == 0)
                {
                    NextFrame();
                }

                if (Activity != CURRENT_ACTIVITY.DIE && IndexCurrent != DieTexture2Ds.Count-1)
                {
                    Activity = CURRENT_ACTIVITY.DIE;
                }
            }
        }

        public override Enemy Clone(int ID, Vector2 topleft)
        {
            Enemy enemy = new Tycoon(ID);
            enemy.Copy(this, topleft);
            return enemy;
        }

        public override void Copy(Enemy origin, Vector2 topleft)
        {
            base.Copy(origin, topleft);
            TycoonTextures = ((Tycoon)origin).TycoonTextures;
        } 
    }
    
}
